package com.leviassaf.androidbasics;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.view.View;
//63
public class CustomAnimationView extends View {
	
	Bitmap bmp;
	//65
	float fltChangingY;
	//66
	Typeface typefaceFont;

	public CustomAnimationView(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
		bmp = BitmapFactory.decodeResource(getResources(), R.drawable.globe);
		//65
		fltChangingY = 0;
		//66
		typefaceFont = Typeface.createFromAsset(context.getAssets(), "dotness.ttf");
	}

	//64
	@Override
	protected void onDraw(Canvas canvas) {
		// TODO Auto-generated method stub
		super.onDraw(canvas);
		canvas.drawColor(Color.WHITE);
		
		//66
		Paint paintText = new Paint();
		paintText.setARGB(50, 255, 34, 98);
		paintText.setTextAlign(Align.CENTER);
		paintText.setTextSize(100);
		paintText.setTypeface(typefaceFont);
		canvas.drawText("Assaf Levi", canvas.getWidth() / 2, 100, paintText);
		
		canvas.drawBitmap(bmp, (canvas.getWidth() / 2), fltChangingY, null);
		if (fltChangingY < canvas.getHeight()){
			fltChangingY += 10;
		}
		else{
			fltChangingY = 0;
		}
		Rect rectMiddle = new Rect();
		rectMiddle.set(0, 400, canvas.getWidth(), 500);
		Paint paint = new Paint();
		paint.setColor(Color.BLUE);
		canvas.drawRect(rectMiddle, paint);
		
		invalidate();
	}

}
